package io.renren.modules.zhaopin.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.zhaopin.dto.ReturnNotifyDto;
import io.renren.modules.zhaopin.entity.BaseAuthInfoEntity;
import io.renren.modules.zhaopin.service.BaseAuthInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 授权信息表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2024-03-24 15:02:38
 */
@RestController
@RequestMapping("/baseAuth/baseauthinfo")
public class BaseAuthInfoController {
    @Autowired
    private BaseAuthInfoService baseAuthInfoService;

    /**
     * 签署完成后同步数据
     */
    @GetMapping("getToken")
    public void getToken() {
        Map<String, Object> map = baseAuthInfoService.getToken();
        Integer code = (Integer) map.get("code");
        if (code == 200) {
            String token = (String) map.get("token");

        }
    }

    /**
     * 签署完成后回调通知
     * @return
     */
    @PostMapping("/returnNotify")
    public Map<String, String> returnNotify(@RequestBody ReturnNotifyDto returnNotifyDto){
        Map<String, String> result = baseAuthInfoService.returnNotify(returnNotifyDto);

        return result;
    }

    /**
     * 签署流程
     * @param reportId
     * @return
     */
    @GetMapping("/eSign")
    public R eSign(String reportId) {
        return baseAuthInfoService.sign(reportId);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:baseauthinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = baseAuthInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:baseauthinfo:info")
    public R info(@PathVariable("id") String id){
		BaseAuthInfoEntity baseAuthInfo = baseAuthInfoService.getById(id);

        return R.ok().put("baseAuthInfo", baseAuthInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:baseauthinfo:save")
    public R save(@RequestBody BaseAuthInfoEntity baseAuthInfo){
		baseAuthInfoService.save(baseAuthInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:baseauthinfo:update")
    public R update(@RequestBody BaseAuthInfoEntity baseAuthInfo){
		baseAuthInfoService.updateById(baseAuthInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:baseauthinfo:delete")
    public R delete(@RequestBody String[] ids){
		baseAuthInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
